﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    ValidateRequest="false" CodeFile="Assignment.aspx.cs" Inherits="Assignment" Title="Assignment - Information Literacy Education" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<%@ Register TagPrefix="uc" TagName="UpdateProgress" Src="~/UserControls/UpdateProgress.ascx" %>
<%@ Register TagPrefix="uc" TagName="UpdateProgress_InPage" Src="~/UserControls/UpdateProgress_InPage.ascx" %>
<%@ Register TagPrefix="uc" TagName="ModalPopupMessage" Src="~/UserControls/ModalPopupMessage.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="Server">

    <script language="javascript" type="text/javascript">
        var BrowserDetect = {
	        init: function () {
		        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		        this.version = this.searchVersion(navigator.userAgent)
			        || this.searchVersion(navigator.appVersion)
			        || "an unknown version";
		        this.OS = this.searchString(this.dataOS) || "an unknown OS";
	        },
	        searchString: function (data) {
		        for (var i=0;i<data.length;i++)	{
			        var dataString = data[i].string;
			        var dataProp = data[i].prop;
			        this.versionSearchString = data[i].versionSearch || data[i].identity;
			        if (dataString) {
				        if (dataString.indexOf(data[i].subString) != -1)
					        return data[i].identity;
			        }
			        else if (dataProp)
				        return data[i].identity;
		        }
	        },
	        searchVersion: function (dataString) {
		        var index = dataString.indexOf(this.versionSearchString);
		        if (index == -1) return;
		        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	        },
	        dataBrowser: [
		        {
		            string: navigator.userAgent,
			        subString: "OmniWeb",
			        versionSearch: "OmniWeb/",
			        identity: "OmniWeb"
		        },
		        {
			        string: navigator.vendor,
			        subString: "Apple",
			        identity: "Safari"
		        },
		        {
			        prop: window.opera,
			        identity: "Opera"
		        },
		        {
			        string: navigator.vendor,
			        subString: "iCab",
			        identity: "iCab"
		        },
		        {
			        string: navigator.vendor,
			        subString: "KDE",
			        identity: "Konqueror"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "Firefox",
			        identity: "Firefox"
		        },
		        {
			        string: navigator.vendor,
			        subString: "Camino",
			        identity: "Camino"
		        },
		        {		// for newer Netscapes (6+)
			        string: navigator.userAgent,
			        subString: "Netscape",
			        identity: "Netscape"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "MSIE",
			        identity: "Explorer",
			        versionSearch: "MSIE"
		        },
		        {
			        string: navigator.userAgent,
			        subString: "Gecko",
			        identity: "Mozilla",
			        versionSearch: "rv"
		        },
		        { 		// for older Netscapes (4-)
			        string: navigator.userAgent,
			        subString: "Mozilla",
			        identity: "Netscape",
			        versionSearch: "Mozilla"
		        }
	        ],
	        dataOS : [
		        {
			        string: navigator.platform,
			        subString: "Win",
			        identity: "Windows"
		        },
		        {
			        string: navigator.platform,
			        subString: "Mac",
			        identity: "Mac"
		        },
		        {
			        string: navigator.platform,
			        subString: "Linux",
			        identity: "Linux"
		        }
	        ]

        };
        BrowserDetect.init(); 
        
        function key(e) {
            var k = 
            document.layers ? e.which :
            document.all ? event.keyCode :
            document.getElementById ? e.keyCode : 0;
            if (k==8) {
                alert('You must use the delete key to delete text');
                return false;
            }
        }
    </script>

    <uc:UpdateProgress ID="updateProgress" runat="server" />
    <asp:UpdatePanel ID="UpdatePanelModalPopupMessage" runat="server">
        <ContentTemplate>
            <uc:ModalPopupMessage ID="ModalPopupMessage" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <h1>
        ILE Assignment</h1>
    <div style="margin-left: 20px;">
        <h4>
            <asp:Label ID="lblCourseSection" runat="server" />
        </h4>
        <div style="margin-left: 20px;">
            <h4>
                <asp:Label ID="lblStandard" runat="server" />
            </h4>
        </div>
    </div>
    <br />
    <h2 style="text-align: center;">
        <asp:Label ID="lblName" runat="server" />
    </h2>
    <asp:UpdatePanel ID="UpdatePanel3" runat="server">
        <ContentTemplate>
            <asp:Panel ID="PanelInstructions" runat="server" Visible="false">
                <br />
                <h3>
                    Instructions:
                </h3>
                <div style="min-width: 600px; border: solid 2px #999; padding: 10px;">
                    <asp:Label ID="lblInstructions" runat="server" />
                    <br />
                    <br />
                    <div style="width: 100%; text-align: right; font-size: smaller;">
                        Due Date :&nbsp;<asp:Label ID="lblAssignmentDueDateTime" runat="server" />
                    </div>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Panel ID="PanelQuiz" runat="server" Visible="false">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:MultiView ID="MultiViewQuiz" runat="server" ActiveViewIndex="0">
                    <asp:View ID="ViewQuizIntroduction" runat="server">
                        <br />
                        <table class="table" style="width: 100%;">
                            <tr style="font-size: 10pt; font-weight: bold; height: 25px;">
                                <td class="tableLeftHeader" style="width: 230px;">
                                    Start Date Time :
                                </td>
                                <td class="tableItem">
                                    <asp:Label ID="lblQuizStartDateTime" runat="server" />
                                </td>
                            </tr>
                            <tr style="font-size: 10pt; font-weight: bold; height: 25px;">
                                <td class="tableLeftHeader">
                                    Due Date Time :
                                </td>
                                <td class="tableItem">
                                    <asp:Label ID="lblQuizDueDateTime" runat="server" />
                                </td>
                            </tr>
                            <tr style="font-size: 10pt; font-weight: bold; height: 25px;">
                                <td class="tableLeftHeader">
                                    Remaining Time :
                                </td>
                                <td class="tableItem">
                                    <asp:Label ID="lblQuizRemainingTime" runat="server" />
                                </td>
                            </tr>
                            <tr style="font-size: 10pt; font-weight: bold; height: 25px;">
                                <td class="tableLeftHeader">
                                    Number of Questions :
                                </td>
                                <td class="tableItem">
                                    <asp:Label ID="lblQuizNumberOfQuestions" runat="server" />
                                </td>
                            </tr>
                            <tr style="font-size: 10pt; font-weight: bold; height: 25px;">
                                <td class="tableLeftHeader">
                                    Maximum Number of Attempts :
                                </td>
                                <td class="tableItem">
                                    <asp:Label ID="lblQuizMaximumNumberOfAttempts" runat="server" />
                                </td>
                            </tr>
                            <tr style="font-size: 10pt; font-weight: bold; height: 25px;">
                                <td class="tableLeftHeader">
                                    Attempts Taken :
                                </td>
                                <td class="tableItem">
                                    <asp:Label ID="lblQuizAttemptsTaken" runat="server" />
                                </td>
                            </tr>
                            <tr style="font-size: 10pt; font-weight: bold; height: 25px;">
                                <td class="tableLeftHeader">
                                    Your Highest Grade :
                                </td>
                                <td class="tableItem">
                                    <asp:Label ID="lblQuizYourHighestGrade" runat="server" />
                                </td>
                            </tr>
                        </table>
                        <br />
                        <div style="min-width: 600px; text-align: center;">
                            <asp:Button ID="btnReturnToModules" runat="server" Text="Return To Module" Width="200"
                                OnClick="btnReturnToModule_Click" />
                            &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:Button ID="btnQuizBegin" runat="server" Text="Begin Quiz" Width="200" OnClick="btnBeginQuiz_Click" /><br />
							<span style="font-weight: Bold;">* Do not use the 'BACK' button.</span>
							
                        </div>
                    </asp:View>
                    <asp:View ID="ViewBeginQuiz" runat="server">
                        <br />
                        <div style="min-height: 200px;">
                            <div style="min-width: 600px; min-height: 30px; text-align: center; font-size: 10pt;">
								<span style="font-weight: Bold;">* Use Question Hyperlinks below to navigate between questions. Do not use the 'BACK' button.</span>
								<br /><br />
                                <asp:Repeater ID="RepeaterQuestionsList" runat="server" OnItemDataBound="RepeaterQuestionsList_ItemDataBound"
                                    OnLoad="RepeaterQuestionsList_Load">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkbtnQuestion" runat="server" OnCommand="lnkbtnQuestion_Click" />
                                    </ItemTemplate>
                                    <SeparatorTemplate>
                                        -
                                    </SeparatorTemplate>
                                </asp:Repeater>
                            </div>
							<br />
                            <h3 style="text-align: center;">
                                Question #<asp:Label ID="lblQuestionNumber" runat="server" /></h3>
                            <div style="">
                                <h5 style="margin-left: 20px;">
                                    Question :</h5>
                                <div style="min-width: 500px; min-height: 70px; margin-left: 30px; padding: 10px 20px 10px 20px;
                                    border: solid 2px #999; font-size: 11pt; font-family: 'Lucida Sans', Arial, Helvetica, sans-serif;">
                                    <asp:Label ID="lblQuizQuestionText" runat="server" />
                                </div>
                                <br />
                                <h5 style="margin-left: 20px;">
                                    Answer(s) :</h5>
                                <div style="min-width: 400px; min-height: 70px; margin-left: 10px; margin-top: -15px;
                                    padding: 10px 50px 10px 50px; font-size: 11pt; font-weight: normal; line-height: 30px;
                                    font-family: 'Lucida Sans', Arial, Helvetica, sans-serif;">
                                    <asp:Repeater ID="RepeaterChoices" runat="server" OnItemDataBound="RepeaterChoices_ItemDataBound">
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkboxChoice" runat="server" AutoPostBack="true" OnCheckedChanged="chkboxChoice_CheckedChanged" />
                                        </ItemTemplate>
                                        <SeparatorTemplate>
                                            <br />
                                        </SeparatorTemplate>
                                    </asp:Repeater>
                                </div>
                            </div>
                        </div>
                        <div style="min-width: 600px; text-align: center;">
                            <asp:Button ID="btnQuestionPrevious" runat="server" Text="Previous" Width="100" OnClick="btnQuestionPrevious_Click" />
                            &nbsp;&nbsp;&nbsp;
                            <asp:Button ID="btnQuestionNext" runat="server" Text="Next" Width="100" OnClick="btnQuestionNext_Click" />
                            <asp:Button ID="btnQuizSubmit" runat="server" Text="Submit" Width="100" Visible="false"
                                OnClick="btnQuizSubmit_Click" />
                            <!-- *SteveMsg-->
                            <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="btnQuizSubmit"
                                ConfirmText="Are you sure you want to submit your quiz?&#10;All questions must be answered in order to submit." />
                        </div>
                    </asp:View>
                </asp:MultiView>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <asp:Panel ID="PanelEssay" runat="server" Visible="false">
        <br />
        <div style="min-width: 600px; text-align: center;">
            <asp:UpdatePanel ID="UpdatePanelAutoSave" runat="server">
                <ContentTemplate>
                    <asp:Label ID="lblEssayMessage" runat="server" />
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnEssayAutoSave" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="btnEssaySave" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
        <asp:MultiView ID="MultiViewEssay" runat="server" ActiveViewIndex="0">
            <asp:View ID="ViewEssay" runat="server">
                <div style="min-width: 600px; text-align: right; padding: 0px 5px 5px 0px;">
                    <uc:UpdateProgress_InPage ID="updateProgress_InPage" runat="server" OnLoad="updateProgress_InPage_Load" />
                </div>
                <FCKeditorV2:FCKeditor ID="EditorEssay" runat="server" BasePath="~/fckeditor/" ToolbarSet="ILE"
                    HtmlEncodeOutput="false" FormatSource="true" FormatOutput="true" Width="100%"
                    Height="400" />
                <%--<uc:ckEditor ID="EditorEssay" runat="server" />--%>
                <%--<cc1:Editor ID="EditorEssay" runat="server" Width="100%" Height="400" InitialCleanUp="true" />--%>
                <div id="Autosave" style="padding: 20px 10px 20px 10px; width: 600px;">
                    <input type="checkbox" id="chkAutoSave" onclick="ToggleAutoSave();" checked="checked" />
                    Please uncheck this box if you want to disable <b>Autosave</b> Feature.<br />
                    <span id="TimeInterval" style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Automatically
                        saves every
                        <input type="text" id="txtTimeInterval" value="3" style="width: 20px;" maxlength="2"
                            onchange="AutoSave('<%=btnEssayAutoSave.ClientID%>');" />
                        minute(s).</span>
                </div>
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <div style="min-width: 620px; text-align: center;">
                            <asp:Button ID="btnEssayReturnToModule" runat="server" Text="Return To Module" OnClick="btnReturnToModule_Click" />
                            <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender3" runat="server" ConfirmText="Are you sure you want to leave this page? Leaving this page does not automatically save the essay."
                                TargetControlID="btnEssayReturnToModule" />
                            &nbsp;&nbsp;&nbsp;
                            <asp:Button ID="btnEssaySave" runat="server" Text="Save Essay" OnClick="btnEssaySave_Click" />
                            &nbsp;&nbsp;&nbsp;
                            <asp:Button ID="btnEssaySubmit" runat="server" Text="Submit Essay" OnClick="btnEssaySubmit_Click" />
                            <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server" TargetControlID="btnEssaySubmit"
                                ConfirmText="Once you submit the Essay, you cannot edit or resubmit. Are you sure you want to submit your essay?" />
                            <div style="display: none;">
                                <asp:Button ID="btnEssayAutoSave" runat="server" Text="AutoSave" OnClick="btnEssayAutoSave_Click" />
                            </div>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:PostBackTrigger ControlID="btnEssaySubmit" />
                    </Triggers>
                </asp:UpdatePanel>
            </asp:View>
            <asp:View ID="ViewAfterSubmit" runat="server">
                <h3>
                    Your submitted Essay:</h3>
                <div style="min-width: 600px; border: solid 2px #999; padding: 10px;">
                    <asp:Label ID="lblEssaySubmitted" runat="server" />
                    <br />
                    <br />
                    <div style="width: 100%; text-align: right; font-size: smaller;">
                        Submitted at&nbsp;<asp:Label ID="lblEssaySubmittedDateTime" runat="server" />
                    </div>
                </div>
                <br />
                <asp:Panel ID="PanelEssayGrade" runat="server" Visible="false">
                    <h3>
                        Your Grade:
                    </h3>
                    <div style="min-width: 600px; border: solid 2px #999; padding: 10px;">
                        <div style="min-width: 600px; font-size: x-large; font-weight: bold; margin-left: 20px;">
                            <asp:Label ID="lblEssayGrade" runat="server" />
                        </div>
                        <br />
                        <h4>
                            Comment from Instructor(s)</h4>
                        <asp:Repeater ID="RepeaterEssayGradeComments" runat="server" OnItemDataBound="RepeaterEssayGradeComments_ItemDataBound">
                            <HeaderTemplate>
                                <table style="min-width: 300px;">
                            </HeaderTemplate>
                            <ItemTemplate>
                                <tr>
                                    <td style="vertical-align: top; font-weight: bold; text-decoration: underline; padding: 10px;">
                                        <asp:Label ID="lblInstructor" runat="server" />
                                        :
                                    </td>
                                    <td style="padding: 10px;">
                                        <asp:Label ID="lblComment" runat="server" />
                                        - <span style="font-size: smaller;">Commented on
                                            <asp:Label ID="lblCommentDateTime" runat="server" /></span>
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater>
                    </div>
                </asp:Panel>
                <br />
                <div style="min-width: 620px; text-align: center;">
                    <asp:Button ID="btnEssayReturnToModule2" runat="server" Text="Return To Module" OnClick="btnReturnToModule_Click"
                        Width="200" />
                </div>
            </asp:View>
        </asp:MultiView>
    </asp:Panel>

    <script language="javascript" type="text/javascript">
        function DisableAutomaticSaving()
        {
            document.getElementById('chkAutoSave').checked = false;
            document.getElementById('TimeInterval').style.display = 'none';
            window.clearInterval(myInterval);
        }
        
        if(BrowserDetect.browser == "Firefox" && BrowserDetect.version <= 2)
        {
            document.getElementById('Autosave').innerHTML = "Autosave feature is not supported on Firefox 1 or 2. To enable autosave, please upgrade to Firefox 3.";
        }
        else if(BrowserDetect.browser == "Explorer")
        {
            document.getElementById('Autosave').innerHTML = "Autosave feature is not supported on Microsoft Internet Explorer. To enable autosave, please use Firefox 3 or higher version.";
        }
        else
        {
            var myInterval = "";
            
            function _Check_Number(val)
            {
	            var regExp = /^[0-9]+$/;
            	
	            if(!regExp.test(val))
	            {
		            return false;
	            }
	            return true;
            }
            
            function ToggleAutoSave()
            {
                var target = document.getElementById('TimeInterval');
                if (target.style.display != 'none')
	            {
		            target.style.display = 'none';
	            }
	            else
	            {
		            target.style.display = '';
	            }
	            AutoSave('<%=btnEssayAutoSave.ClientID%>');
            }
            
            function manualClick(ClientID)
            {
                document.getElementById(ClientID).click();
            }
            
            function AutoSave(ClienID)
            {
                var IsAutoSaveEnabled = document.getElementById('chkAutoSave').checked;
                if(IsAutoSaveEnabled)
                {
                    var TimeInterval = document.getElementById('txtTimeInterval').value;
                    var command = "manualClick('" + ClienID + "');";
                    if(!_Check_Number(TimeInterval))
                    {
                        alert('Time Interval should be numeric number.');
                        document.getElementById('txtTimeInterval').value = 1;
                        return false;
                    }
                    else
                    {
                        if (TimeInterval < 1)
                        {
                            alert('Time Interval cannot be smaller than 1 minute.');
                            document.getElementById('txtTimeInterval').value = 1;
                            return false;
                        }
                    }
                    
                    window.clearInterval(myInterval);
                    myInterval = window.setInterval( command , TimeInterval * 1000 * 60 );
                    return true;
                }
                else
                {
                    window.clearInterval(myInterval);
                }
            }
            
            AutoSave('<%=btnEssayAutoSave.ClientID%>');
        }
    </script>

</asp:Content>
